<?php
namespace APP\Controller;
use Think\Controller;
class CommentsController extends Controller{
	public function commentslist(){
		/*尹京华--显示评论列表方法*/
		$commentsmodel =M('comments');
		$comments=$commentsmodel->order('comments_id asc')->select();
		echo json_encode($comments);
	}

	public function commentsadd($shaitu_id,$comments_content,$uid ){
		/*尹京华--添加评论列表方法*/
		/*http://localhost/yuejian6/index.php/APP/Comments/commentsadd/shaitu_id/1/comments_content/jsdfhjdskfh/comments_date/2017-8-25%2017:52:12/uid/1*/
		$commentsmodel =M('comments');
		// $data['shaitu_id']=$shaitu_id;
		// $data['uid']=$uid;
		// $data['comments_content']=$comments_content;
		// $data['comments_date']=date('Y-m-d H:i:s');
		$commentsmodel->shaitu_id=$shaitu_id;
		$commentsmodel->uid=$uid;
		$commentsmodel->comments_content=$comments_content;
		$commentsmodel->comments_date=date('Y-m-d H:i:s');
        $re=$commentsmodel->add();	
			if ($re>0)
		    {
		    	echo "{'result':true}";
			}
			else
			{
				echo "{'result':false}";
			}
	}

	public function commentsdel($comments_id){
		/*尹京华--删除评论接口*/
		$commentsmodel=M('comments');
		// $comments=$commentsmodel->where("comments_id=$comments_id")->find();
        if (false !== $commentsmodel->where("comments_id=$comments_id")->delete())
        {
            echo "{'result':true}";
        } else {
				echo "{'result':false}";
        }

	}

	// public function commentsedit($comments_id){
	// 	/*尹京华--修改评论接口*/
	// 	$commentsmodel =M('comments');
	// 	$comments=$commentsmodel->where("comments_id=$comments_id")->find();
	// 	$this->comments=$comments;
	// 	$this->display();
	// }

	// public function commentsupdate(){
	// 	/*尹京华--修改评论接口*/
	// 	$commentsmodel =D('comments');
	// 	// $comments = $commentsmodel->where("comments_id=$code")->find();
	// 	if($commentsmodel->create()){
	// 		$reg=$commentsmodel->save();
 //           if (false!==$reg) {
 //            echo "{'result':true}";
 //        } else {
	// 			echo "{'result':false}";
 //        } 

	// 	}
	// }
}
?>